<template>
  <vxe-grid
    ref="table"
    size="medium"
    border="none"
    height="100%"
    width="100%"
    :data="data"
    :columns="realColumns"
    :scroll-y="{enabled: true}"
    :has-pager="false"
    show-overflow
    v-bind="$attrs"
    v-on="$listeners"
  >
    <!-- vxe-grid原有插槽 -->
    <template
      v-for="(index, name) in $slots"
      #[name]="{row,column, }"
    >
      <slot
        :name="name"
        :row="row"
        :column="column"
      />
    </template>
  </vxe-grid>
</template>

<script>
export default {
  name: 'ScrollTable',
  props: {
    columns: {
      type: Array,
      default: () => []
    },
    data: {
      type: Array,
      default: () => []
    },
    // 暂无此需求
    loadFunction: {
      type: Function,
      default: () => { return [] }
    }
  },
  data () {
    return {
    }
  },
  computed: {
    realColumns () {
      const result = this.$props.columns.map((item) => {
        return {
          ...item,
          title: item.label ? item.label : item.title,
          align: item.align ? item.align : 'center'
        }
      })
      return result
    }
  }
}
</script>

<!-- <style lang="scss" scoped>

</style> -->
